<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <script src="js/jquery.min.js"></script>
    <script>
        function mysub(type) {
            var username = jQuery("#username");
            var password = jQuery("#password");
            if (type == 2) {
                if (confirm("是否确认清空？")) {
                    // 执行清空操作
                    username.val(""); // 清空
                    password.val("");
                }
                return false;
            }
            if (username.val().trim() == "") {
                alert("请先输入用户名！");
                username.focus();
                return false;
            }
            if (password.val().trim() == "") {
                alert("请先输入密码！");
                password.focus();
                return false;
            }
            // 判断密码和确认密码是否一致
            jQuery.getJSON("login",{
                "username":username.val(),
                "password":password.val()
            },function (data) {
                if(data != null && data.state == 200) {
                    location.href = "index.html";
                }else {
                    alert("登录失败!");
                }
            })
        }
    </script>
</head>
<body>
<div style="margin-top: 70px;text-align: center;">
    <font face="宋体" size="5" color="red"><strong>---登录---</strong></font><p></p>
    用户名：<input id="username" name="username" type="text" style="background-color: bisque"><p></p>
    &nbsp;密&nbsp;&nbsp;码：<input id="password" name="password" type="password" style="background-color: bisque"><p></p>
    <input type="button" value="提交" onclick="mysub(1)" style="background-color: aquamarine">&nbsp;&nbsp;&nbsp;
    <input type="button" value="清空" onclick="mysub(2)" style="background-color: aquamarine">
    <p></p>
    <a href="regin.html">注册...</a>
</div>
</body>
</html>